<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>时钟表</title>
	<style type="text/css">
	#shizhong {
		height: 50px;
		width: 400px;
		border: 1px solid #ccc;
		background-color: blue;}
		
	#shizhong div{
		height: 50px;
		width: 100px;
		float: left;

	}
	</style>
	<script language="javascript">
<!--
window.onload = function  () {
	function getTime()
		{
		var first = new Date();//现在的时间
		var last = new Date('2018/01/01 00:00:00');//将来的的时间
		var t=last.getTime()-first.getTime();//获得的时间差
		var s = 0;//初始时间
		var m = 0;
		var h = 0;
		var d = 0;
		//判断
		 if(t>=0){
		 	d = Math.floor(t/1000/3600/24);
		 	h = Math.floor (t/1000/60/60%24);
		 	m = Math.floor(t/1000/60%60);
		 	s = Math.floor(t/1000%60)
		 }
		 document.getElementById("t_d").innerHTML =d+"天";
		 document.getElementById("t_h").innerHTML =h+"小时";
		 document.getElementById("t_m").innerHTML =m+"分";
		 document.getElementById("t_s").innerHTML =s+"秒";

		 
		 }
		 setInterval(getTime,1000)
	}
</script>
</head>
<body>
<div id="shizhong">
	<div id = "t_d"></div>
	<div id = "t_h"></div>
	<div id = "t_m"></div>
	<div id = "t_s"></div>


</div> 

	
</body>
</html>